
<template>

  <div class="block">
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>用户信息</el-breadcrumb-item>
    </el-breadcrumb>
    <br>
    <el-form :inline="true" :model="formInline" class="user-search">
  <el-form-item label="姓名">
    <el-input v-model="formInline.data.username"    placeholder="请输入姓名"></el-input>
  </el-form-item>
  <el-form-item label="电话">
    <el-input v-model="formInline.data.phone"  placeholder="请输入电话"></el-input>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="search">搜索</el-button>
  </el-form-item>
</el-form>

    <el-table :data="tableData" border style="width: 100%">
      <el-table-column fixed prop="id" label="序号" width="80">
      </el-table-column>
      <el-table-column prop="username" label="姓名" width="120"> </el-table-column>
      <el-table-column prop="mpassword" label="管理员密码" width="120">
      </el-table-column>
      <el-table-column prop="apassword" label="App密码" width="120">
      </el-table-column>
      <el-table-column prop="name" label="角色" width="120"> </el-table-column>
      <el-table-column prop="sex" label="性别" width="120"> </el-table-column>
      <el-table-column prop="phone" label="电话" width="120"> </el-table-column>
      <el-table-column prop="address" label="住址" width="250">
      </el-table-column>
      <el-table-column prop="email" label="邮箱" width="120"> </el-table-column>
      <el-table-column fixed="right" label="操作" width="100">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small"
            >查看</el-button
          >
          <el-button type="text"  @click="delect(scope.row)" size="small">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  
    <span class="demonstration"></span>
    <!-- <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage4"
      :page-sizes="[100, 200, 300, 400]"
      :page-size="100"
      layout="total, sizes, prev, pager, next, jumper"
      :total="400">
    </el-pagination> -->
    <Pagination
      v-bind:child-msg="pageparm"
      @callFather="callFather"
    ></Pagination>
  </div>
</template>

<script>
import errorVue from '../../components/error.vue';
import Pagination from "../../components/Pagination";
export default {
  // 注册组件
  components: {
    Pagination,
  },
  created() {
    this.getdata(this.formInline);
  },
  
  methods: {  
    handleClick(row) {
      console.log(row);
      this.$router.push({ path: '/information/Userupdate', query:{id: row.id} })
    },
    delect(row){
      console.log(row.id)
        this.$axios.post("/api/user/updateStatus",{
          id:row.id
        }).then(res=>{
         if(res.data.code==200){
            console.log("成功")
          this.getdata(this.formInline)
         }else{
           console.log("修改失败")-errorVue
         }
          
        })
    },
    
      // 分页插件事件
    callFather(parm) {
      this.formInline.page = parm.currentPage;
      this.formInline.limit = parm.pageSize;
      this.getdata(this.formInline);
    },
    search() {
      this.getdata(this.formInline);
      //展示页面在1第一页
      this.formInline.page = 1;
      //展示分页下标在第一页
      this.pageparm.currentPage = 1;
    },
    getdata(){
      this.$axios.post('/api/user/findAllUser/',this.formInline).then(res=>{
        console.log(res.data.data.list);
        console.log(res.data.code);
        
        if(res.data.code==200){
          this.tableData = res.data.data.list
          this.pageparm.currentPage = this.formInline.page
          this.pageparm.pageSize = this.formInline.limit
          this.pageparm.total = res.data.data.total;
          
        }else {
         console.log(res.data.data.msg)
        }

      })
    }
  },

  data() {
    return {
      tableData: [
        {
          id: " ",
          username: " ",
          mpassword: " ",
          apassword: " ",
          name: " ",
          sex: " ",
          phone: " ",
          address: " ",
          email: " ",
        },
       
       
      ],
      formInline: {
          
          //设置加载初始页
          page: 1,
        //设置加载初始条数
          limit: 5,
          data:{
            username: '',
            phone: '',
          },
        },
        pageparm: {
        currentPage: 1,
        pageSize: 10,
        total: 10,
      },
    };
  },
};
</script>



